/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

Ext.define("Market.controller.Societa",{
    extend: 'Ext.app.Controller',
    init: function(){
        this.control({
            'societalist': {
                itemdblclick: this.editUser
            },
            'societaedit button[action=save]':{
                click: this.updateUser
            }
        });        
    },
    
    editUser:  function(grid,record){
         var view = Ext.widget('societaedit');

        view.down('form').loadRecord(record);
    },
    updateUser: function(button){
        var win    = button.up('window'),
        form   = win.down('form'),
        record = form.getRecord(),
        values = form.getValues();
        record.set(values);
        win.close();
        
        this.getSocietaStore().sync();
        
    },
    views: [
    'societa.List',
    'societa.Edit'
    ],
    stores: ['Societa'],
    models: ['Societa']
    
    
})